package com.autoTools.view;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Label;
import java.awt.Panel;
import java.awt.ScrollPane;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.ScrollPaneConstants;

import com.autoTools.util.Constants;
import com.autoTools.util.LogUtil;

public class ScorllView extends BaseView {
	private ScrollPane mScrollPane = null;
	private JPanel mPanel = null;
	static final String TAG = "ScorllView";
	
	public ScorllView() {
		mScrollPane = new ScrollPane();
		
		mPanel = new JPanel();
		BoxLayout boxLayout = new BoxLayout(mPanel, BoxLayout.Y_AXIS);
		mPanel.setLayout(boxLayout);
		mScrollPane.add(mPanel);
		BaseInit(mScrollPane);
	}

	public boolean addChild(BaseView child) {
		boolean state = false;
		if (child != null) {
			if (child.getParent() != null) {
				state = false;
			} else {
				if (child.getInstance() instanceof Component) {
					if (child.getProperty().get(Constants.CONSTRAINTS) != null) {
						mPanel.add((Component) child.getInstance(), child.getProperty().get(Constants.CONSTRAINTS));
					} else {
						mPanel.add((Component) child.getInstance());
					}
					state = super.addChild(child);
				} else {
					LogUtil.sysLog(TAG, "addChild Error:child is not extends Component");
				}
			}
		}
		return state;
	}

	public void setLabel(String label) {
		super.setLabel(label);
	}
}
